package com.hksj.common.log.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hksj.common.core.model.Rest;

import com.hksj.common.log.dto.LoginRecordLogDTO;
import com.hksj.common.log.dto.OperationRecordLogDTO;
import com.hksj.common.log.service.LogService;
import com.hksj.common.log.service.LoginRecordLogService;
import com.hksj.common.log.service.OperationRecordLogService;
import com.hksj.common.log.dto.SystemRecordLogDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hksj.common.log.service.SystemRecordLogService;
import com.hksj.common.log.vo.LoginRecordLogVO;
import com.hksj.common.log.vo.OperationRecordLogVO;
import com.hksj.common.log.vo.SystemRecordLogVO;

import javax.annotation.Resource;

/**
 * @author zengke
 * @version 1.0
 * @see LogController
 * @since 2024/3/12 8:41
 */
@Api(tags = "日志管理")
@RestController
@RequestMapping("/api/log")
public class LogController {

    @Resource
    private LogService logService;

    @Resource
    private SystemRecordLogService systemRecordLogService;

    @Resource
    private OperationRecordLogService operationRecordLogService;

    @Resource
    @Qualifier(value = "loginRecordServiceLog")
    private LoginRecordLogService loginRecordLogService;

    @ApiOperation(value = "查询系统日志列表")
    @PostMapping("/querySystemRecordList")
    public Rest<Page<SystemRecordLogVO>> querySystemLogRecordList(@RequestBody SystemRecordLogDTO dto){
        Page<SystemRecordLogVO> systemRecordList = systemRecordLogService.querySystemRecordList(dto);
        return Rest.ok(systemRecordList);
    }

    @ApiOperation(value = "查询操作日志列表")
    @PostMapping("/queryOperationRecordList")
    public Rest<Page<OperationRecordLogVO>> queryOperationRecordList(@RequestBody OperationRecordLogDTO dto){
        Page<OperationRecordLogVO> operationRecordList = operationRecordLogService.queryOperationRecordList(dto);
        return Rest.ok(operationRecordList);
    }

    @ApiOperation(value = "查询登录日志列表")
    @PostMapping("/queryLoginRecordList")
    public Rest<Page<LoginRecordLogVO>> queryLoginRecordList(@RequestBody LoginRecordLogDTO dto){
        Page<LoginRecordLogVO> loginRecordList = loginRecordLogService.queryLoginRecordList(dto);
        return Rest.ok(loginRecordList);
    }
}
